package utils.properties;

import java.io.*;
import java.util.*;
import javax.swing.JOptionPane;

/**
 *
 * @author Juan Carlos García
 */
public class YourJavaPropertiesUtils {
    
    public static String fileName = "";
    public static Properties props = new Properties();
    private static String path = "src/conf/";
    
    public static String getProperty(String property,String name){
        
                
        try{
            fileName = name;
            FileInputStream in = new FileInputStream(path+fileName+".properties");
            props.load(in);
            in.close();
       
        }catch(Exception e2){
            
            JOptionPane.showMessageDialog(null, e2.getMessage());
        }
  
        String var = props.getProperty(property);
        
        return var;
    }
    
    
    public static void setProperty(String property,String value,String pathName){
        try{
        fileName = pathName;
        FileInputStream fis = new FileInputStream(path+fileName+".properties");
        props.load(fis);
        props.setProperty(property,value);
        FileOutputStream out = new FileOutputStream(path+fileName+".properties");
        props.store(out,null);
        }catch(Exception e2){
            JOptionPane.showMessageDialog(null,e2.getMessage());
        }
        
        
    }
    
}
